package com.shazhu.web.controller.nongjt;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.shazhu.common.annotation.Log;
import com.shazhu.common.core.controller.BaseController;
import com.shazhu.common.core.domain.AjaxResult;
import com.shazhu.common.enums.BusinessType;
import com.shazhu.nongjt.domain.CertHighspeedPrintTask;
import com.shazhu.nongjt.service.ICertHighspeedPrintTaskService;
import com.shazhu.common.utils.poi.ExcelUtil;
import com.shazhu.common.core.page.TableDataInfo;

/**
 * 合格证高速打印任务Controller
 * 
 * @author shazhu
 * @date 2025-09-29
 */
@RestController
@RequestMapping("/nongjt/task")
public class CertHighspeedPrintTaskController extends BaseController
{
    @Autowired
    private ICertHighspeedPrintTaskService certHighspeedPrintTaskService;

    /**
     * 查询合格证高速打印任务列表
     */
    @PreAuthorize("@ss.hasPermi('nongjt:task:list')")
    @GetMapping("/list")
    public TableDataInfo list(CertHighspeedPrintTask certHighspeedPrintTask)
    {
        startPage();
        List<CertHighspeedPrintTask> list = certHighspeedPrintTaskService.selectCertHighspeedPrintTaskList(certHighspeedPrintTask);
        return getDataTable(list);
    }

    /**
     * 导出合格证高速打印任务列表
     */
    @PreAuthorize("@ss.hasPermi('nongjt:task:export')")
    @Log(title = "合格证高速打印任务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CertHighspeedPrintTask certHighspeedPrintTask)
    {
        List<CertHighspeedPrintTask> list = certHighspeedPrintTaskService.selectCertHighspeedPrintTaskList(certHighspeedPrintTask);
        ExcelUtil<CertHighspeedPrintTask> util = new ExcelUtil<CertHighspeedPrintTask>(CertHighspeedPrintTask.class);
        util.exportExcel(response, list, "合格证高速打印任务数据");
    }

    /**
     * 获取合格证高速打印任务详细信息
     */
    @PreAuthorize("@ss.hasPermi('nongjt:task:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(certHighspeedPrintTaskService.selectCertHighspeedPrintTaskById(id));
    }

    /**
     * 新增合格证高速打印任务
     */
    @PreAuthorize("@ss.hasPermi('nongjt:task:add')")
    @Log(title = "合格证高速打印任务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CertHighspeedPrintTask certHighspeedPrintTask)
    {
        return toAjax(certHighspeedPrintTaskService.insertCertHighspeedPrintTask(certHighspeedPrintTask));
    }

    /**
     * 修改合格证高速打印任务
     */
    @PreAuthorize("@ss.hasPermi('nongjt:task:edit')")
    @Log(title = "合格证高速打印任务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CertHighspeedPrintTask certHighspeedPrintTask)
    {
        return toAjax(certHighspeedPrintTaskService.updateCertHighspeedPrintTask(certHighspeedPrintTask));
    }

    /**
     * 删除合格证高速打印任务
     */
    @PreAuthorize("@ss.hasPermi('nongjt:task:remove')")
    @Log(title = "合格证高速打印任务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(certHighspeedPrintTaskService.deleteCertHighspeedPrintTaskByIds(ids));
    }
}
